﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Workflow.ComponentModel;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.ComponentModel.Compiler;

namespace Chapter3
{
    class Program
    {
        static void Main(string[] args)
        {
            Run("Sequence.xoml");
        }

        static void Run(string xomlName)
        {
            using (WorkflowRuntime runtime = new WorkflowRuntime())
            {
                TypeProvider typeProvider = new TypeProvider(runtime);
                typeProvider.AddAssemblyReference("EssentialWF.dll");

                runtime.AddService(typeProvider);
                runtime.StartRuntime();

                WorkflowInstance instance = null;
                using (XmlTextReader reader = new XmlTextReader(xomlName))
                {
                    instance = runtime.CreateWorkflow(reader);
                    instance.Start();
                }

                

                //string s = Console.ReadLine();
                //instance.EnqueueItem("r1", s, null, null);

                Console.ReadLine();
                runtime.StopRuntime();

                Console.ReadLine();
            }
        }
    }
}
